<template>
    <div class="content">
        <img :src="img"
                class="hd-img-responsive">
        <div class="hd-article">
            <div class="title">{{title}}</div>
            <div class="subtitle">{{subtitle}}</div>
            <div class="hd-content" v-html="content">
            </div>
        </div>
    </div>
</template>

<script>
import { yiqinggetxinfen, yiqinggettufen } from '@/api/yi-qing-fang-kong.js'
export default {
  name: 'index',
  data () {
    return {
      type: this.$route.query.type,
      id: this.$route.query.id,
      title: '',
      subtitle: '',
      content: '',
      img: ''
    }
  },
  methods: {
    init () {
      let data = {
        id: this.id
      }
      if (this.type === 'analysis') {
        yiqinggetxinfen(data).then(ret => {
          if (ret.data.errcode === 0) {
            this.title = ret.data.data.result[0].title
            this.subtitle = ret.data.data.result[0].datetime
            this.content = ret.data.data.result[0].wenzi
          }
        })
      }
      if (this.type === 'trends') {
        yiqinggettufen(data).then(ret => {
          if (ret.data.errcode === 0) {
            this.title = ret.data.data.result[0].title
            this.img = ret.data.data.result[0].url
            this.content = ret.data.data.result[0].wenzi
          }
        })
      }
    }
  },
  mounted () {
    this.init()
  }
}
</script>

<style scoped>
    .title{
        font-size: 14px;
    }
    .subtitle{
        font-size: 12px;
    }
    .content >>> .hd-article p{
        font-size: 14px !important;
    }
</style>
